/*
EP3D is a real-time 3D planet engine , which in addition to providing 
substandard scene rendering and scene management, of course, it also 
provides some basic class libraries to build the entire virtual 
planet, or even the entire universe.

Copyright (C) 2010  Hongjiang Zhang	(zhjwyat@gmail.com)

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef EP3D_STREAM_H
#define EP3D_STREAM_H
#include "EP3DRefCounter.h"
#include "EP3DPointer.h"

namespace EP3D
{
	SmartPointer(IStream)
	class EP3DEXPORT IStream
		:public AutoRefCounter
	{
	public:
		IStream(void)
			:m_bIsError(false)
		{}

		virtual ~IStream(void)
		{}

		virtual int Read(void* pvBuffer, int nSize)
		{
			return 0;
		}

		virtual void Seek(int nPos, bool bRelative = false)
		{}

		virtual bool Close()
		{
			return m_bIsError;
		}

		virtual bool Eof() const
		{
			int pos = Tell();
			return pos != -1 && pos >= GetSize();
		}

		virtual int GetSize() const
		{
			return -1;
		}

		virtual int Tell() const
		{
			return -1;
		}

		virtual bool IsError() const
		{
			return !m_bIsError;
		}

	protected:
		bool m_bIsError;
	};


	SmartPointer(OStream)
	class EP3DEXPORT OStream
		:public AutoRefCounter
	{
	public:
		OStream(void)
			:m_bIsError(false)
		{}

		virtual ~OStream(void)
		{}

		virtual void Write(const void* pvBuffer, int nSize)
		{}

		virtual void Seek(int nPos, bool bRelative = false)
		{}

		virtual void Flush()
		{}

		virtual bool Close()
		{
			return !m_bIsError;
		}

		virtual bool Eof() const
		{
			int pos = Tell();
			return pos != -1 && pos >= GetSize();
		}

		virtual int GetSize() const
		{
			return -1;
		}

		virtual int Tell() const
		{
			return -1;
		}

		virtual bool IsError() const
		{
			return m_bIsError;
		}
	protected:
		bool m_bIsError;
	};

}
#endif
